package com.aaa.controller;

import com.aaa.service.S_CheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/check/")
public class S_CheckController {
    @Autowired
    private S_CheckService service;

    /** 定向到网页
     * @return
     */
    @RequestMapping("check")
    public  String toCheck(){
        return "publicity/check";
    }

    @RequestMapping("selNews")
    @ResponseBody
    public Object selNews(@RequestBody(required = false) Map map){
        List<Map> data=service.selNews(map);
        Integer total=service.getCount(map);
        List<Map> list=service.selName();
        Map zmap=new HashMap();
        zmap.put("data",data);
        zmap.put("total",total);
        zmap.put("options",list);
        return zmap;
    }


    /** 审核通过事件
     * @return
     */

    @RequestMapping("pass/{id}")
    @ResponseBody
    public Integer pass(@PathVariable Integer id){
        int row=service.pass(id);
        return row;
    }

    @RequestMapping("reject/{id}")
    @ResponseBody
    public Integer reject(@PathVariable Integer id){
        int row=service.reject(id);
        return row;
    }
}
